local sk__zhaxiang = fk.CreateSkill {

  name = "sk__zhaxiang",

  tags = {},

}



sk__zhaxiang:addEffect("active", {
  name = "sk__zhaxiang",
  anim_type = "offensive",
  card_num = 1,
  target_num = 1,
  prompt = "#sk__zhaxiang",
  can_use = function(self, player)
    return not player:isKongcheng()
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local card = effect.cards[1]
    room:moveCardTo(card, Card.Void, nil, fk.ReasonJustMove, sk__zhaxiang.name, nil, false, player)
    local cards = room:askForCard(target, 1, 1, true, sk__zhaxiang.name, true, ".", "#sk__zhaxiang-give:" .. player.id)
    if #cards > 0 then
      room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, sk__zhaxiang.name, nil, false, player)
      if player.dead then
        room:moveCardTo(card, Card.DiscardPile, nil, fk.ReasonJustMove, sk__zhaxiang.name, nil, true, nil)
      else
        room:moveCardTo(card, Card.DiscardPile, nil, fk.ReasonDiscard, sk__zhaxiang.name, nil, true, player)
      end
    else
      local yes = Fk:getCardById(card).trueName == "slash"
      room:moveCardTo(card, Card.PlayerHand, target, fk.ReasonJustMove, sk__zhaxiang.name, nil, true, player)
      if yes and not target.dead then
        room:useVirtualCard("fire__slash", nil, player, target, sk__zhaxiang.name, true)
      end
    end
  end,
})

return sk__zhaxiang
